package dto

const (
	CodeSuccess                  Code = "10000" // 接口调用成功
	CodeOrderSuccessPayInProcess Code = "10003" // 表示订单创建成功，支付处理中
	CodeUnknowError              Code = "20000" // 服务不可用
	CodeInvalidAuthToken         Code = "20001" // 授权权限不足
	CodeMissingParam             Code = "40001" // 缺少必选参数
	CodeInvalidParam             Code = "40002" // 非法的参数
	CodeInsufficientConditions   Code = "40003" // 条件异常
	CodeBusinessFailed           Code = "40004" // 业务处理失败
	CodeCallLimited              Code = "40005" // 调用频次超限
	CodePermissionDenied         Code = "40006" // 权限不足
)

type Code string

func (c Code) IsSuccess() bool {
	return c == CodeSuccess || c == CodeOrderSuccessPayInProcess
}

func (c Code) IsFailure() bool {
	return !c.IsSuccess()
}

type Error struct {
	Code    Code   `json:"code"`
	Msg     string `json:"msg"`
	SubCode string `json:"sub_code"`
	SubMsg  string `json:"sub_msg"`
}
